Skip to main content

Custom Sources API Documentation

Base URL: https://api.chataid.com

Authorization: All endpoints require a valid Authorization: <YOUR_API_KEY> header. Your API key must be having the permission to interact with these APIs.


1. List Custom Sources

GET /external/sources/custom

Retrieve a paginated list of custom sources for your organisation. Supports filtering and pagination.

Query Parameters

NameTypeRequiredDescription
namestringOptionalFilter by source name (partial, case-insensitive)
statusstringOptionalFilter by source status
typestringOptionalFilter by source type
adminIdstringOptionalFilter by admin Mongo ID
teamIdstringOptionalFilter by team Mongo ID
createdAtFromstringOptionalFilter by createdAt start date (ISO8601)
createdAtTostringOptionalFilter by createdAt end date (ISO8601)
pagenumberOptionalPage number (default: 1)
pageSizenumberOptionalPage size (default: 100, max: 1000)

Example cURL

curl -X GET "https://api.chataid.com/external/sources/custom?page=1&pageSize=10" \
-H "Authorization: <YOUR_API_KEY>"

Success Response

  • Status: 200 OK
  • Body:
{
"ok": true,
"data": [
{
"id": "string",
"name": "string",
"status": "string",
"type": "string",
"url": "string",
"adminIds": ["string"],
"teamIds": ["string"],
"description": {
"ai": "string",
"user": "string"
},
"error": "string",
"createdAt": "string",
"lastTrainingStartedAt": "string",
"lastTrainingAttemptedAt": "string",
"lastTrainType": "string",
"wordCount": "number",
"usageCounts": "number"
}
],
"page": 1,
"pageSize": 100,
"total": 1,
"totalPages": 1
}

2. Get Custom Source by ID

GET /external/sources/custom/:id

Retrieve a single custom source by its ID.

URL Parameters

NameTypeRequiredDescription
idstringRequiredThe custom source Mongo ID

Example cURL

curl -X GET "https://api.chataid.com/external/sources/custom/<SOURCE_ID>" \
-H "Authorization: <YOUR_API_KEY>"

Success Response

  • Status: 200 OK
  • Body:
{
"ok": true,
"data": {
"id": "string",
"name": "string",
"status": "string",
"type": "string",
"url": "string",
"adminIds": ["string"],
"teamIds": ["string"],
"description": {
"ai": "string",
"user": "string"
},
"error": "string",
"createdAt": "string",
"lastTrainingStartedAt": "string",
"lastTrainingAttemptedAt": "string",
"lastTrainType": "string",
"wordCount": "number",
"usageCounts": "number"
}
}

Error Response

  • Status: 404 Not Found
  • Body:
{
"ok": false,
"message": "Custom source not found"
}

3. Add Custom Sources (File Upload)

POST /external/sources/custom

Add new custom sources by uploading one or more files.

This endpoint requires a multipart/form-data request. Use the files field to upload one or more files.

Query Parameters

NameTypeRequiredDescription
teamIdstringOptionalThe Mongo ID of the Team where you want to add the sources

Body (multipart/form-data)

FieldTypeRequiredDescription
filesFile[]RequiredOne or more files to upload

Supported File Formats

The following file formats are supported for upload:

  • PDF (.pdf)
  • Microsoft Word (.doc, .docx)
  • Microsoft PowerPoint (.ppt, .pptx)
  • Microsoft Excel (.xls, .xlsx)
  • Text (.txt)
  • Markdown (.md)
  • CSV (.csv)
  • HTML (.html)
  • Rich Text Format (.rtf)
  • Images (.png, .jpg, .jpeg, .gif)

Example cURL

curl -X POST "https://api.chataid.com/external/sources/custom?teamId=<TEAM_ID>" \
-H "Authorization: <YOUR_API_KEY>" \
-F "files=@/path/to/file1.pdf" \
-F "files=@/path/to/file2.docx"

Success Response

  • Status: 200 OK
  • Body:
{
"ok": true,
"message": "Started training on X sources successfully."
}

Error Response

  • Status: 400 Bad Request
  • Body:
{
"ok": false,
"message": "Error message (e.g., unsupported file type, already added, etc.)"
}

4. Delete Multiple Custom Sources

DELETE /external/sources/custom

Delete multiple custom sources by IDs or by filters.

You can pass either ids or filters in the request body:

  • ids: Deletes the specific documents with those IDs.
  • filters: Deletes all documents matching the filter criteria.

If neither is provided, all custom sources from your organisation will be deleted.

Body (JSON)

FieldTypeRequiredDescription
idsarrayOptionalArray of custom source document IDs to delete. Deletes only these documents.
filtersobjectOptionalFilter object to select sources to delete. Deletes all documents matching the filter.

Filter Object Fields

FieldTypeRequiredDescription
namestringOptionalFilter by document name
statusstringOptionalFilter by document status
typestringOptionalFilter by document type
adminIdstringOptionalFilter by admin user ID
teamIdstringOptionalFilter by team ID
createdAtFromstringOptionalFilter by created at from (ISO8601)
createdAtTostringOptionalFilter by created at to (ISO8601)

Example cURLs

Delete by IDs:

curl -X DELETE "https://api.chataid.com/external/sources/custom" \
-H "Authorization: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"ids": ["id1", "id2"]}'

Delete by Filters:

curl -X DELETE "https://api.chataid.com/external/sources/custom" \
-H "Authorization: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"filters": {"status": "error"}}'

Success Response

  • Status: 200 OK
  • Body:
{
"ok": true,
"deletedCount": 25
}

5. Delete Custom Source by ID

DELETE /external/sources/custom/:id

Delete a single custom source by its ID.

URL Parameters

NameTypeRequiredDescription
idstringRequiredThe custom source Mongo ID

Example cURL

curl -X DELETE "https://api.chataid.com/external/sources/custom/<SOURCE_ID>" \
-H "Authorization: <YOUR_API_KEY>"

Success Response

  • Status: 200 OK
  • Body:
{
"ok": true
}

Common Errors

  • 401 Unauthorized: Authentication required.
  • 403 Forbidden: Your API Key do not have permission to access this resource.
  • 404 Not Found: Resource not found.
  • 400 Bad Request: Invalid input or parameters.